#ifndef MAILBOX_H_
#define MAILBOX_H_

#include "confFile.h"
#include "blockingQueue.h"


//Process mailbox message
typedef struct pMessage{
	char* messageText;			//message text
	int vAddr;					//vitrual address	//used as pid in prm
	int offset;					//offset			//user as pageNum in prm
	int byteAmmount; 			//byte ammount
	char* fileName;				//file name to save to
	char* stringParam;			//the string to write
}pMessage_t;

void createMessage(pMessage_t* message, char* messageText, int vAddr,
		int offset, int byteAmmount, char* fileName, char* stringParam);	//create message
void killMessage(pMessage_t* message);	//free message

void mbox_init(blockingQueue* queue);					//init the mailbox
void mbox_enqueue(blockingQueue* mbox, pMessage_t* message);	//add message to the mailbox
pMessage_t* mbox_dequeue(blockingQueue* mbox);				//get message from the mailbox and remove from queue
void mbox_clean(blockingQueue* mbox);					//clean all messages from the mailbox, including freeing ptrs
void mbox_kill(blockingQueue* mbox);					//free all nodes pointers and free mailbox ptr

#endif /*MAILBOX_H_*/
